<?php
session_start();
require("../../adodb/adodb.inc.php");
require("../../Connections/forms2.php");
require_once("../../makesql.php");
require_once("../../procfunc.php");
require_once("../../firmaorigen.php");
$SQL="SELECT * FROM preguntas WHERE idpreg=$idpreg";
$preg=$forms2->Execute($SQL) or DIE ("Error en la consulta");
ob_start();
//echo '<pre>';var_dump($_REQUEST);echo '</pre>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Buscador</title>
<link href="<?=$basedir."/style/style.css";?>" rel="stylesheet" type="text/css">
<!-- JQuery -->
<script type="text/javascript" src="<?=$basedir;?>/jscript/jquery/jquery.min.js"></script>
<!-- JQuery PriceFormat -->
<script src="<?=$basedir;?>/jscript/jquery/plugins/priceFormat/jquery.price_format.1.3.js" type="text/javascript"></script>
<!-- JQuery Validate -->
<script src="<?=$basedir;?>/jscript/jquery/plugins/jquery-validate/jquery.validate.min.js" type="text/javascript"></script>
<script src="<?=$basedir;?>/jscript/jquery/plugins/jquery-validate/additional-methods.js" type="text/javascript"></script>
<script src="<?=$basedir;?>/jscript/jquery/plugins/jquery-validate/localization/messages_es.js" type="text/javascript"></script>
<script language="javascript">
 $(document).ready(function(){
	$("#form1").validate();
});
</script>
</head>
<table cellspacing="0" cellpadding="4">
  <tr>
    <td><div class='msgbox'>
        <form id="form1" name="form1" method="post" action="Empresas.php">
          <table width="100%" border="0" cellpadding="0" cellspacing="2" class="pregunta">
            <tr>
              <td colspan="3" nowrap="nowrap" class="smalltext">Ingrese el l CUIT de la Empresa y haga click en &quot;Buscar&quot;</td>
              <td width="4%" rowspan="4" class="smalltext"><p>&nbsp;</p></td>
            </tr>
            <tr>
              <td width="9%" valign="middle" nowrap="nowrap" class="smalltext">C.U.I.T:</td>
              <td width="22%" valign="middle" nowrap="nowrap"><input type="text" name="cuit" id="cuit" value="<?=$cuit?>"  size="14" class="inbox" cuit="true" /></td>
              <td width="65%" valign="middle">&nbsp;</td>
            </tr>
            <tr>
              <td class="smalltext" nowrap="nowrap"></td>
              <td><span class="smalltext">
                <input type="submit" name="Submit" value="Buscar" class="inbox" />
                <input type="hidden" name="idpreg" value=<?=$idpreg;?> />
				<input type="hidden" name="nombrecontrol" value=<?=$nombrecontrol;?> />
                <?=$mydir;?>
                <input type="hidden" name="idap" value="<?=$idap;?>"/>
              </span></td>
              <td>&nbsp;</td>
            </tr>
          </table>
        </form>
        </div></td>
  </tr>
</table>
      <?php 

if ($cuit<>"" or $nombre<>'') {
$idform=$preg->Fields('param1');
$origidform=$idform;
$tipo=$idform[0];
$idform=substr($idform,1);
	if ($tipo=="V"){
	$param="idvista=$idform&idap=$idap";
	} else {
	$param="idform=$idform&idap=$idap";
	}
//$forms2->debug=true;
if($cuit<>'')
$SQL="SELECT * FROM td_empresas INNER JOIN idsent ON td_empresas.id=idsent.id WHERE idpreg=1695 AND valor LIKE '%$cuit%' AND idsent.estado IN ('activa','validar')";
$res=$forms2->Execute($SQL) or DIE ("Error en la consulta");
if($res->RecordCount()){
?>Haga click en "Agregar" para incorporar la empresa, si desea incorporar otra vuelva a realizar la búsqueda.
      <table border="0" cellspacing="2" cellpadding="2">
        <tr bgcolor="#FFFFFF" class="seccioncolor">
          <td class="smalltext">&nbsp;</td>
          <td class="smalltext">Nombre</td>
          <td class="smalltext">C.U.I.T</td>
          <td class="smalltext">Provincia</td>
          <td class="smalltext">Partido</td>
          <td class="smalltext">Localidad</td>
          <td class="smalltext">Domicilio</td>
          <td class="smalltext">Origen</td>
        </tr>
        <?php 
  while (!$res->EOF){
  $id=$res->Fields("id");
  if($preg->Fields('param2')){
  //----hay que chequear la vista
  $link="$basedir/RenderEdit/editnew.php?$param&child=$idpreg&childcont=$nombrecontrol&nonav=true&id=$id";
  } else {
  //----se puede agregar directamente
  $link="javascript:window.parent.tb_remove();window.parent.addsel('$id','$idpreg','".$preg->Fields('nombrecontrol')."');";
  }
  ?>
        <tr bgcolor="#FFFFFF">
          <td class="smalltext" align="center"><a href="<?=$link;?>" title="Cargar/agregar"> <strong><img src="<?=$basedir;?>/<?=$basedir;?>/ImagenCustom/add.gif" alt="agregar" width="16" height="16" border="0" align="absmiddle" >&nbsp;Agregar</strong></a></td>
          <td class="smalltext"><?=getvalor(1693)?></td>
          <td class="smalltext" align="center"><?=getvalor(1695)?></td>
          <td class="smalltext"><?=@array_shift(getvalor(4651));
		  ?></td>
          <td class="smalltext"><?=@array_shift(getvalor(1699));
		  ?></td>
          <td class="smalltext"><?=@array_shift(getvalor(1700));?></td>
          <td class="smalltext"><?=trim(getvalor(4653).' '.getvalor(4654).' '.getvalor(4655));?></td>
          <td class="smalltext"><?=getvalor(1797);?></td>
        </tr>
        <?php
  $res->Movenext();
  }?>
      </table>
      <p>
  <?php } else {
$link="$basedir/RenderEdit/editnew.php?$param&child=$idpreg&childcont=$nombrecontrol&nonav=true&id=$id";
  ?>
No se han encontrado resultados, puede incorporar la empresa en el Registro de Empresas.
<script language="javascript">
enabled=window.parent.document.getElementById('enabled_<?=$idpreg;?>');
disabled=window.parent.document.getElementById('disabled_<?=$idpreg;?>');
disabled.style.visibility='hidden';
disabled.style.width='0px';
disabled.style.position='absolute';
enabled.style.visibility='visible';;
</script>
      <br>
</p>
<p>o click <a href="javascript:window.parent.tb_remove();"><strong>&gt;&gt;AQUI&lt;&lt; </strong></a>para cerrar.
        <?php }
}?>
            </p>
<?php
$out = ob_get_contents();
ob_end_clean();
//echo utf8_encode($out);
echo $out;
?>